package com.ruoyi.cloudcourse.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.cloudcourse.mapper.FeatherSpecialMapper;
import com.ruoyi.cloudcourse.domain.FeatherSpecial;
import com.ruoyi.cloudcourse.service.IFeatherSpecialService;
import com.ruoyi.common.core.text.Convert;

/**
 * 专题Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-07-14
 */
@Service
public class FeatherSpecialServiceImpl implements IFeatherSpecialService 
{
    @Autowired
    private FeatherSpecialMapper featherSpecialMapper;

    /**
     * 查询专题
     * 
     * @param specialId 专题ID
     * @return 专题
     */
    @Override
    public FeatherSpecial selectFeatherSpecialById(Long specialId)
    {
        return featherSpecialMapper.selectFeatherSpecialById(specialId);
    }

    /**
     * 查询专题列表
     * 
     * @param featherSpecial 专题
     * @return 专题
     */
    @Override
    public List<FeatherSpecial> selectFeatherSpecialList(FeatherSpecial featherSpecial)
    {
        return featherSpecialMapper.selectFeatherSpecialList(featherSpecial);
    }

    /**
     * 新增专题
     * 
     * @param featherSpecial 专题
     * @return 结果
     */
    @Override
    public int insertFeatherSpecial(FeatherSpecial featherSpecial)
    {
        return featherSpecialMapper.insertFeatherSpecial(featherSpecial);
    }

    /**
     * 修改专题
     * 
     * @param featherSpecial 专题
     * @return 结果
     */
    @Override
    public int updateFeatherSpecial(FeatherSpecial featherSpecial)
    {
        return featherSpecialMapper.updateFeatherSpecial(featherSpecial);
    }

    /**
     * 删除专题对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteFeatherSpecialByIds(String ids)
    {
        return featherSpecialMapper.deleteFeatherSpecialByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除专题信息
     * 
     * @param specialId 专题ID
     * @return 结果
     */
    @Override
    public int deleteFeatherSpecialById(Long specialId)
    {
        return featherSpecialMapper.deleteFeatherSpecialById(specialId);
    }

    @Override
    public int deleteJudge(String ids) {
        int count = featherSpecialMapper.selectCourseCountBySpecialIds(Convert.toStrArray(ids));
        if (count == 0){
            return deleteFeatherSpecialByIds(ids);
        }
        return 0;
    }
}
